<?php
    /**
     * Created by PhpStorm.
     * User: liaoxiaohua
     * Date: 2018/6/28
     * Time: 上午11:58
     */

namespace app\common\validate;



use app\common\exception\ErrorException;
use app\common\service\Sms;
use think\facade\Request;
use think\Validate;

class BaseValidate extends Validate
{
    public function goCheck($scene='')
    {
        $params = Request::param();
        if(!$this->scene($scene)->check($params)){
            throw new ErrorException(422,200,$this->error);
        }else{
            return $params;
        }
    }
    /*
     * 手机验证码校验
     */
    protected function checkMobileVerify($value,$rule,$data){
        if (is_string($rule)) {
            $rule = explode(',', $rule);
        }
        list($field, $type) = $rule;
        $verify = $data[$field];
        return Sms::check($value,$verify,$type);
    }
}